<template>
  <div class="wrapper">
    <div class="container">
      <div class="card" v-for="p in pages" :key="p" @click="handleClick(p)">
        <img :src="p + '.webp'" :alt="p" class="card-img" />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useRouter } from "vue-router";

const pages = ref<string[]>([]);
const router = useRouter();

const modules = import.meta.glob("/src/views/*.vue");
const keys = Object.keys(modules).map((item) =>
  item.replace("/src/views/", "").replace(".vue", "")
);
pages.value = keys;

function handleClick(page: string) {
  router.push({ name: page });
}
</script>

<style lang="less">
.wrapper {
  height: 100vh;
  padding: 20px;
  box-sizing: border-box;
  background: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);
}
.container {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-flow: row;
  gap: 20px;
}
.card {
  height: 200px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.5s ease-in-out;
  font-size: 24px;
  color: white;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  padding: 1px;
}
.card:hover {
  transform: scale(1.05);
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.2);
}
.card-img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
</style>
